using System.Collections.Generic;
using System.IO;
using JsonRpcGen.TypeHandler;
using Newtonsoft.Json.Linq;

namespace JsonRpcGen.ParameterHandler
{
    internal class EnumParamHandler : ParamHandler
    {
        private string _className;
        private EnumTypeHandler _typeHandler;
        private bool _done;

        public EnumParamHandler(string name, JToken jToken, string className):base(name,className)
        {
            _className = className;
            _typeHandler = new EnumTypeHandler(jToken);
        }

        public override void WriteType(StreamWriter writer, Dictionary<string, string> replacements)
        {
            if (!_done)
            {
                _typeHandler.WriteEnum(writer, _className);
                _done = true;
            }
        }

        public override string GetDefault()
        {
            return "0";
        }
    }
}